home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / doc / octave.i08 (.txt) < prev    next >
GNU Info File  |  1997-08-20  |  46KB  |  991 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3. START-INFO-DIR-ENTRY
  4. * Octave: (octave).     Interactive language for numerical computations.
  5. END-INFO-DIR-ENTRY
  6.    Copyright (C) 1996, 1997 John W. Eaton.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions.
  17. File: octave,  Node: Differential-Algebraic Equations,  Prev: Ordinary Differential Equations,  Up: Differential Equations
  18. Differential-Algebraic Equations
  19. ================================
  20.    The function `dassl' can be used Solve DAEs of the form
  21.      0 = f (x-dot, x, t),    x(t=0) = x_0, x-dot(t=0) = x-dot_0
  22. using Petzold's DAE solver DASSL.
  23.  - Loadable Function: [X, XDOT] = dassl (FCN, X0, XDOT0, T, T_CRIT)
  24.      Return a matrix of states and their first derivatives with respect
  25.      to T.  Each row in the result matrices correspond to one of the
  26.      elements in the vector T.  The first element of T corresponds to
  27.      the initial state X0 and derivative XDOT0, so that the first row
  28.      of the output X is X0 and the first row of the output XDOT is
  29.      XDOT0.
  30.      The first argument, FCN, is a string that names the function to
  31.      call to compute the vector of residuals for the set of equations.
  32.      It must have the form
  33.           RES = f (X, XDOT, T)
  34.      where X, XDOT, and RES are vectors, and T is a scalar.
  35.      The second and third arguments to `dassl' specify the initial
  36.      condition of the states and their derivatives, and the fourth
  37.      argument specifies a vector of output times at which the solution
  38.      is desired, including the time corresponding to the initial
  39.      condition.
  40.      The set of initial states and derivatives are not strictly
  41.      required to be consistent.  In practice, however, DASSL is not
  42.      very good at determining a consistent set for you, so it is best
  43.      if you ensure that the initial values result in the function
  44.      evaluating to zero.
  45.      The fifth argument is optional, and may be used to specify a set of
  46.      times that the DAE solver should not integrate past.  It is useful
  47.      for avoiding difficulties with singularities and points where
  48.      there is a discontinuity in the derivative.
  49.  - Loadable Function:  dassl_options (OPT, VAL)
  50.      When called with two arguments, this function allows you set
  51.      options parameters for the function `lsode'.  Given one argument,
  52.      `dassl_options' returns the value of the corresponding option.  If
  53.      no arguments are supplied, the names of all the available options
  54.      and their current values are displayed.
  55.    See K. E. Brenan, et al., `Numerical Solution of Initial-Value
  56. Problems in Differential-Algebraic Equations', North-Holland (1989) for
  57. more information about the implementation of DASSL.
  58. File: octave,  Node: Optimization,  Next: Statistics,  Prev: Differential Equations,  Up: Top
  59. Optimization
  60. ************
  61. * Menu:
  62. * Quadratic Programming::
  63. * Nonlinear Programming::
  64. * Linear Least Squares::
  65. File: octave,  Node: Quadratic Programming,  Next: Nonlinear Programming,  Prev: Optimization,  Up: Optimization
  66. Quadratic Programming
  67. =====================
  68. File: octave,  Node: Nonlinear Programming,  Next: Linear Least Squares,  Prev: Quadratic Programming,  Up: Optimization
  69. Nonlinear Programming
  70. =====================
  71. File: octave,  Node: Linear Least Squares,  Prev: Nonlinear Programming,  Up: Optimization
  72. Linear Least Squares
  73. ====================
  74.  - Function File: [BETA, V, R] = gls (Y, X, O)
  75.      Generalized least squares estimation for the multivariate model `Y
  76.      = X * B + E' with `mean (E) = 0' and `cov (vec (E)) = (S^2)*O',
  77.      where Y is a T by P matrix, X is a T by K matrix, B is a K by P
  78.      matrix, E is a T by P matrix, and O is a TP by TP matrix.
  79.      Each row of Y and X is an observation and each column a variable.
  80.      The return values BETA, V, and R are defined as follows.
  81.     BETA
  82.           The GLS estimator for B.
  83.     V
  84.           The GLS estimator for `S^2'.
  85.     R
  86.           The matrix of GLS residuals, `R = Y - X * BETA'.
  87.  - Function File: [BETA, SIGMA, R] = ols (Y, X)
  88.      Ordinary least squares estimation for the multivariate model `Y =
  89.      X*B + E' with `mean (E) = 0' and `cov (vec (E)) = kron (S, I)'.
  90.      where Y is a T by P matrix, X is a T by K matrix, B is a K by P
  91.      matrix, and E is a T by P matrix.
  92.      Each row of Y and X is an observation and each column a variable.
  93.      The return values BETA, SIGMA, and R are defined as follows.
  94.     BETA
  95.           The OLS estimator for B, `BETA = pinv (X) * Y', where `pinv
  96.           (X)' denotes the pseudoinverse of X.
  97.     SIGMA
  98.           The OLS estimator for the matrix S,
  99.                SIGMA = (Y-X*BETA)' * (Y-X*BETA) / (T-rank(X))
  100.     R
  101.           The matrix of OLS residuals, `R = Y - X * BETA'.
  102. File: octave,  Node: Statistics,  Next: Sets,  Prev: Optimization,  Up: Top
  103. Statistics
  104. **********
  105.    I hope that someday Octave will include more statistics functions.
  106. If you would like to help improve Octave in this area, please contact
  107. (bug-octave@bevo.che.wisc.edu).
  108.  - Function File:  mean (X)
  109.      If X is a vector, compute the mean of the elements of X
  110.           mean (x) = SUM_i x(i) / N
  111.      If X is a matrix, compute the mean for each column and return them
  112.      in a row vector.
  113.  - Function File:  median (X)
  114.      If X is a vector, compute the median value of the elements of X.
  115.                       x(ceil(N/2)),             N odd
  116.           median(x) =
  117.                       (x(N/2) + x((N/2)+1))/2,  N even
  118.      If X is a matrix, compute the median value for each column
  119.      and return them in a row vector.
  120.  - Function File:  std (X)
  121.      If X is a vector, compute the standard deviation of the elements
  122.      of X.
  123.           std (x) = sqrt (sumsq (x - mean (x)) / (n - 1))
  124.      If X is a matrix, compute the standard deviation for each
  125.      column and return them in a row vector.
  126.  - Function File:  cov (X, Y)
  127.      If each row of X and Y is an observation and each column is a
  128.      variable, the (I,J)-th entry of `cov (X, Y)' is the covariance
  129.      between the I-th variable in X and the J-th variable in Y.  If
  130.      called with one argument, compute `cov (X, X)'.
  131.  - Function File:  corrcoef (X, Y)
  132.      If each row of X and Y is an observation and each column is a
  133.      variable, the (I,J)-th entry of `corrcoef (X, Y)' is the
  134.      correlation between the I-th variable in X and the J-th variable
  135.      in Y.  If called with one argument, compute `corrcoef (X, X)'.
  136.  - Function File:  kurtosis (X)
  137.      If X is a vector of length N, return the kurtosis
  138.           kurtosis (x) = N^(-1) std(x)^(-4) sum ((x - mean(x)).^4) - 3
  139.      of X.  If X is a matrix, return the row vector containing the
  140.      kurtosis of each column.
  141.  - Function File:  mahalanobis (X, Y)
  142.      Return the Mahalanobis' D-square distance between the multivariate
  143.      samples X and Y, which must have the same number of components
  144.      (columns), but may have a different number of observations (rows).
  145.  - Function File:  skewness (X)
  146.      If X is a vector of length N, return the skewness
  147.           skewness (x) = N^(-1) std(x)^(-3) sum ((x - mean(x)).^3)
  148.      of X.  If X is a matrix, return the row vector containing the
  149.      skewness of each column.
  150. File: octave,  Node: Sets,  Next: Polynomial Manipulations,  Prev: Statistics,  Up: Top
  151.    Octave has a limited set of functions for managing sets of data,
  152. where a set is defined as a collection unique elements.
  153.  - Function File:  create_set (X)
  154.      Return a row vector containing the unique values in X, sorted in
  155.      ascending order.  For example,
  156.           create_set ([ 1, 2; 3, 4; 4, 2 ])
  157.                => [ 1, 2, 3, 4 ]
  158.  - Function File:  union (X, Y)
  159.      Return the set of elements that are in either of the sets X and Y.
  160.      For example,
  161.           union ([ 1, 2, 4 ], [ 2, 3, 5 ])
  162.                => [ 1, 2, 3, 4, 5 ]
  163.  - Function File:  intersection (X, Y)
  164.      Return the set of elements that are in both sets X and Y.  For
  165.      example,
  166.           intersection ([ 1, 2, 3 ], [ 2, 3, 5 ])
  167.                => [ 2, 3 ]
  168.  - Function File:  complement (X, Y)
  169.      Return the elements of set Y that are not in set X.  For example,
  170.           complement ([ 1, 2, 3 ], [ 2, 3, 5 ])
  171.                => 5
  172. File: octave,  Node: Polynomial Manipulations,  Next: Control Theory,  Prev: Sets,  Up: Top
  173. Polynomial Manipulations
  174. ************************
  175.    In Octave, a polynomial is represented by its coefficients (arranged
  176. in descending order).  For example, a vector  C of length  N+1
  177. corresponds to the following polynomial of order  N
  178.      p(x) = C(1) x^N + ... + C(N) x + C(N+1).
  179.  - Function File:  compan (C)
  180.      Compute the companion matrix corresponding to polynomial
  181.      coefficient vector C.
  182.      The companion matrix is
  183.                _                                                        _
  184.               |  -c(2)/c(1)   -c(3)/c(1)  ...  -c(N)/c(1)  -c(N+1)/c(1)  |
  185.               |       1            0      ...       0             0      |
  186.               |       0            1      ...       0             0      |
  187.           A = |       .            .   .            .             .      |
  188.               |       .            .       .        .             .      |
  189.               |       .            .           .    .             .      |
  190.               |_      0            0      ...       1             0     _|
  191.      The eigenvalues of the companion matrix are equal to the roots of
  192.      the polynomial.
  193.  - Function File:  conv (A, B)
  194.      Convolve two vectors.
  195.      `y = conv (a, b)' returns a vector of length equal to `length (a)
  196.      + length (b) - 1'.  If A and B are polynomial coefficient vectors,
  197.      `conv' returns the coefficients of the product polynomial.
  198.  - Function File:  deconv (Y, A)
  199.      Deconvolve two vectors.
  200.      `[b, r] = deconv (y, a)' solves for B and R such that `y = conv
  201.      (a, b) + r'.
  202.      If Y and A are polynomial coefficient vectors, B will contain the
  203.      coefficients of the polynomial quotient and R will be a remander
  204.      polynomial of lowest order.
  205.  - Function File:  poly (A)
  206.      If A is a square N-by-N matrix, `poly (A)' is the row vector of
  207.      the coefficients of `det (z * eye (N) - a)', the characteristic
  208.      polynomial of A.  If X is a vector, `poly (X)' is a vector of
  209.      coefficients of the polynomial whose roots are the elements of X.
  210.  - Function File:  polyderiv (C)
  211.      Return the coefficients of the derivative of the polynomial whose
  212.      coefficients are given by vector C.
  213.  - Function File:  polyfit (N, Y, N)
  214.      Return the coefficients of a polynomial P(X) of degree N that
  215.      minimizes `sumsq (p(x(i)) - y(i))',  to best fit the data in the
  216.      least squares sense.
  217.  - Function File:  polyinteg (C)
  218.      Return the coefficients of the integral the polynomial whose
  219.      coefficients are represented by the vector C.
  220.      The constant of integration is set to zero.
  221.  - Function File:  polyreduce (C)
  222.      Reduces a polynomial coefficient vector to a minimum number of
  223.      terms by stripping off any leading zeros.
  224.  - Function File:  polyval (C, X)
  225.      Evaluate a polynomial.
  226.      `polyval (C, X)' will evaluate the polynomial at the specified
  227.      value of X.
  228.      If X is a vector or matrix, the polynomial is evaluated at each of
  229.      the elements of X.
  230.  - Function File:  polyvalm (C, X)
  231.      Evaluate a polynomial in the matrix sense.
  232.      `polyvalm (C, X)' will evaluate the polynomial in the matrix
  233.      sense, i.e. matrix multiplication is used instead of element by
  234.      element multiplication as is used in polyval.
  235.      The argument X must be a square matrix.
  236.  - Function File:  residue (B, A, TOL)
  237.      If B and A are vectors of polynomial coefficients, then residue
  238.      calculates the partial fraction expansion corresponding to the
  239.      ratio of the two polynomials.
  240.      The function `residue' returns R, P, K, and E, where the vector R
  241.      contains the residue terms, P contains the pole values, K contains
  242.      the coefficients of a direct polynomial term (if it exists) and E
  243.      is a vector containing the powers of the denominators in the
  244.      partial fraction terms.
  245.      Assuming B and A represent polynomials  P (s) and Q(s)  we have:
  246.            P(s)    M       r(m)         N
  247.            ---- = SUM -------------  + SUM k(i)*s^(N-i)
  248.            Q(s)   m=1 (s-p(m))^e(m)    i=1
  249.      where M is the number of poles (the length of the R, P, and E
  250.      vectors) and N is the length of the K vector.
  251.      The argument TOL is optional, and if not specified, a default
  252.      value of 0.001 is assumed.  The tolerance value is used to
  253.      determine whether poles with small imaginary components are
  254.      declared real.  It is also used to determine if two poles are
  255.      distinct.  If the ratio of the imaginary part of a pole to the
  256.      real part is less than TOL, the imaginary part is discarded.  If
  257.      two poles are farther apart than TOL they are distinct.  For
  258.      example,
  259.            b = [1, 1, 1];
  260.            a = [1, -5, 8, -4];
  261.            [r, p, k, e] = residue (b, a);
  262.                => r = [-2, 7, 3]
  263.                => p = [2, 2, 1]
  264.                => k = [](0x0)
  265.                => e = [1, 2, 1]
  266.      which implies the following partial fraction expansion
  267.                   s^2 + s + 1       -2        7        3
  268.              ------------------- = ----- + ------- + -----
  269.              s^3 - 5s^2 + 8s - 4   (s-2)   (s-2)^2   (s-1)
  270.  - Function File:  roots (V)
  271.      For a vector V with N components, return the roots of the
  272.      polynomial
  273.           v(1) * z^(N-1) + ... + v(N-1) * z + v(N).
  274. File: octave,  Node: Control Theory,  Next: Signal Processing,  Prev: Polynomial Manipulations,  Up: Top
  275. Control Theory
  276. **************
  277.    Most of the functions described in this chapter were contributed by
  278. A. Scottedward Hodel (A.S.Hodel@eng.auburn.edu) and R. Bruce Tenison
  279. (Bruce.Tenison@eng.auburn.edu).  They have also written a larger
  280. collection of functions for solving linear control problems.  It is
  281. currently being updated for Octave version 2, with snapshots of the
  282. sources available from (ftp://ftp.eng.auburn.edu/pub/hodel).
  283.  - Function File: [N, M, P] = abcddim (A, B, C, D)
  284.      Check for compatibility of the dimensions of the matrices defining
  285.      the linear system [A, B, C, D] corresponding to
  286.           dx/dt = a x + b u
  287.           y = c x + d u
  288.      or a similar discrete-time system.
  289.      If the matrices are compatibly dimensioned, then `abcddim' returns
  290.     N
  291.           The number of system states.
  292.     M
  293.           The number of system inputs.
  294.     P
  295.           The number of system outputs.
  296.      Otherwise `abcddim' returns N = M = P = -1.
  297.  - Function File:  are (A, B, C, OPT)
  298.      Return the solution, X, of the algebraic Riccati equation
  299.           a' * x + x * a - x * b * x + c = 0
  300.      for identically dimensioned square matrices A, B, and C.  If B is
  301.      not square, `are' attempts to use `B*B'' instead.  If C is not
  302.      square, `are' attempts to use `C'*C') instead.
  303.      To form the solution, Laub's Schur method (IEEE Transactions on
  304.      Automatic Control, 1979) is applied to the appropriate Hamiltonian
  305.      matrix.
  306.      The optional argument OPT is passed to the eigenvalue balancing
  307.      routine.  If it is omitted, a value of `"B"' is assumed.
  308.  - Function File:  c2d (A, B, T)
  309.      Convert the continuous time system described by:
  310.           dx/dt = a x + b u
  311.      into a discrete time equivalent model
  312.           x[k+1] = Ad x[k] + Bd u[k]
  313.      via the matrix exponential assuming a zero-order hold on the input
  314.      and sample time T.
  315.  - Function File:  dare (A, B, C, R, OPT)
  316.      Return the solution, X of the discrete-time algebraic Riccati
  317.      equation
  318.           a' x a - x + a' x b (r + b' x b)^(-1) b' x a + c = 0
  319.      for matrices with dimensions:
  320.     A
  321.           N by N.
  322.     B
  323.           N by M.
  324.     C
  325.           N by N, symmetric positive semidefinite.
  326.     R
  327.           M by M, symmetric positive definite (invertible).
  328.      If C is not square, then the function attempts to use `C'*C'
  329.      instead.
  330.      To form the solution, Laub's Schur method (IEEE Transactions on
  331.      Automatic Control, 1979) is applied to the appropriate symplectic
  332.      matrix.
  333.      See also Ran and Rodman, `Stable Hermitian Solutions of Discrete
  334.      Algebraic Riccati Equations', Mathematics of Control, Signals and
  335.      Systems, Volume 5, Number 2 (1992).
  336.      The optional argument OPT is passed to the eigenvalue balancing
  337.      routine.  If it is omitted, a value of `"B"' is assumed.
  338.  - Function File:  dgram (A, B)
  339.      Return the discrete controllability or observability gramian for
  340.      the discrete time system described by
  341.           x[k+1] = A x[k] + B u[k]
  342.             y[k] = C x[k] + D u[k]
  343.      For example, `dgram (A, B)' returns the discrete controllability
  344.      gramian and `dgram (A', C')' returns the observability gramian.
  345.  - Function File: [L, M, P, E] = dlqe (A, G, C, SIGW, SIGV, Z)
  346.      Construct the linear quadratic estimator (Kalman filter) for the
  347.      discrete time system
  348.           x[k+1] = A x[k] + B u[k] + G w[k]
  349.             y[k] = C x[k] + D u[k] + w[k]
  350.      where W, V are zero-mean gaussian noise processes with respective
  351.      intensities `SIGW = cov (W, W)' and `SIGV = cov (V, V)'.
  352.      If specified, Z is `cov (W, V)'.  Otherwise `cov (W, V) = 0'.
  353.      The observer structure is
  354.           z[k+1] = A z[k] + B u[k] + k(y[k] - C z[k] - D u[k])
  355.      The following values are returned:
  356.     L
  357.           The observer gain, (A - ALC).  is stable.
  358.     M
  359.           The Riccati equation solution.
  360.     P
  361.           The estimate error covariance after the measurement update.
  362.     E
  363.           The closed loop poles of (A - ALC).
  364.  - Function File: [K, P, E] = dlqr (A, B, Q, R, Z)
  365.      Construct the linear quadratic regulator for the discrete time
  366.      system
  367.           x[k+1] = A x[k] + B u[k]
  368.      to minimize the cost functional
  369.           J = Sum (x' Q x + u' R u)
  370.      Z omitted or
  371.           J = Sum (x' Q x + u' R u + 2 x' Z u)
  372.      Z included.
  373.      The following values are returned:
  374.     K
  375.           The state feedback gain, (A - BK) is stable.
  376.     P
  377.           The solution of algebraic Riccati equation.
  378.     E
  379.           The closed loop poles of (A - BK).
  380.  - Function File:  dlyap (A, B)
  381.      Solve the discrete-time Lyapunov equation `a x a' - x + b = 0' for
  382.      square matrices A, B.  If B is not square, then the function
  383.      attempts to solve either `a x a' - x + b b' = 0' or `a' x a - x +
  384.      b' b = 0', whichever is appropriate.
  385.      Uses Schur decomposition method as in Kitagawa `An Algorithm for
  386.      Solving the Matrix Equation X = FXF' + S', International Journal
  387.      of Control, Volume 25, Number 5, pages 745-753 (1977);
  388.      column-by-column solution method as suggested in Hammerling,
  389.      `Numerical Solution of the Stable, Non-Negative Definite Lyapunov
  390.      Equation', IMA Journal of Numerical Analysis, Volume 2, pages
  391.      303-323 (1982).
  392.  - Function File:  is_controllable (A, B, TOL)
  393.      Return 1 if the pair (A, B) is controllable.  Otherwise, return 0.
  394.      The optional argument TOL is a roundoff parameter.  If it is
  395.      omitted, a value of `2*eps' is used.
  396.      Currently, `is_controllable' just constructs the controllability
  397.      matrix and checks rank.
  398.  - Function File:  is_observable (A, C, TOL)
  399.      Return 1 if the pair (A, C) is observable.  Otherwise, return 0.
  400.      The optional argument TOL is a roundoff parameter.  If it is
  401.      omitted, a value of `2*eps' is used.
  402.  - Function File: [K, P, E] = lqe (A, G, C, SIGW, SIGV, Z)
  403.      Construct the linear quadratic estimator (Kalman filter) for the
  404.      continuous time system
  405.           dx
  406.           -- = a x + b u
  407.           dt
  408.           
  409.           y = c x + d u
  410.      where W and V are zero-mean gaussian noise processes with
  411.      respective intensities
  412.           sigw = cov (w, w)
  413.           sigv = cov (v, v)
  414.      The optional argument Z is the cross-covariance `cov (W, V)'.  If
  415.      it is omitted, `cov (W, V) = 0' is assumed.
  416.      Observer structure is `dz/dt = A z + B u + k (y - C z - D u)'
  417.      The following values are returned:
  418.     K
  419.           The observer gain, (A - KC) is stable.
  420.     P
  421.           The solution of algebraic Riccati equation.
  422.     E
  423.           The vector of closed loop poles of (A - KC).
  424.  - Function File: [K, P, E] = lqr (A, B, Q, R, Z)
  425.      construct the linear quadratic regulator for the continuous time
  426.      system
  427.           dx
  428.           -- = A x + B u
  429.           dt
  430.      to minimize the cost functional
  431.                 infinity
  432.                 /
  433.             J = |  x' Q x + u' R u
  434.                /
  435.               t=0
  436.      Z omitted or
  437.                 infinity
  438.                 /
  439.             J = |  x' Q x + u' R u + 2 x' Z u
  440.                /
  441.               t=0
  442.      Z included.
  443.      The following values are returned:
  444.     K
  445.           The state feedback gain, (A - BK) is stable.
  446.     P
  447.           The stabilizing solution of appropriate algebraic Riccati
  448.           equation.
  449.     E
  450.           The vector of the closed loop poles of (A - BK).
  451.  - Function File:  lyap (A, B, C)
  452.      Solve the Lyapunov (or Sylvester) equation via the Bartels-Stewart
  453.      algorithm (Communications of the ACM, 1972).
  454.      If A, B, and C are specified, then `lyap' returns the solution of
  455.      the  Sylvester equation
  456.           a x + x b + c = 0
  457.      If only `(a, b)' are specified, then `lyap' returns the solution
  458.      of the Lyapunov equation
  459.           a' x + x a + b = 0
  460.      If B is not square, then `lyap' returns the solution of either
  461.           a' x + x a + b' b = 0
  462.      or
  463.           a x + x a' + b b' = 0
  464.      whichever is appropriate.
  465.  - Function File:  tzero (A, B, C, D, OPT)
  466.      Compute the transmission zeros of [A, B, C, D].
  467.      The optional argument OPT is passed to the eigenvalue balancing
  468.      routine.  If it is omitted, a value of `"B"' is assumed.
  469. File: octave,  Node: Signal Processing,  Next: Image Processing,  Prev: Control Theory,  Up: Top
  470. Signal Processing
  471. *****************
  472.    I hope that someday Octave will include more signal processing
  473. functions.  If you would like to help improve Octave in this area,
  474. please contact (bug-octave@bevo.che.wisc.edu).
  475.  - Function File:  detrend (X, P)
  476.      If X is a vector, `detrend (X, P)' removes the best fit of a
  477.      polynomial of order P from the data X.
  478.      If X is a matrix, `detrend (X, P)' does the same for each column
  479.      in X.
  480.      The second argument is optional.  If it is not specified, a value
  481.      of 1 is assumed.  This corresponds to removing a linear trend.
  482.  - Function:  fft (A, N)
  483.      Compute the FFT of A using subroutines from FFTPACK.  If A is a
  484.      matrix, `fft' computes the FFT for each column of A.
  485.      If called with two arguments, N is expected to be an integer
  486.      specifying the number of elements of A to use.  If A is a matrix,
  487.      N specifies the number of rows of A to use.  If N is larger than
  488.      the size of A, A is resized and padded with zeros.
  489.  - Loadable Function:  ifft (A, N)
  490.      Compute the inverse FFT of A using subroutines from FFTPACK.  If A
  491.      is a matrix, `fft' computes the inverse FFT for each column of A.
  492.      If called with two arguments, N is expected to be an integer
  493.      specifying the number of elements of A to use.  If A is a matrix,
  494.      N specifies the number of rows of A to use.  If N is larger than
  495.      the size of A, A is resized and padded with zeros.
  496.  - Loadable Function:  fft2 (A, N, M)
  497.      Compute the two dimensional FFT of A.
  498.      The optional arguments N and M may be used specify the number of
  499.      rows and columns of A to use.  If either of these is larger than
  500.      the size of A, A is resized and padded with zeros.
  501.  - Loadable Function:  ifft2 (A, N, M)
  502.      Compute the two dimensional inverse FFT of A.
  503.      The optional arguments N and M may be used specify the number of
  504.      rows and columns of A to use.  If either of these is larger than
  505.      the size of A, A is resized and padded with zeros.
  506.  - Built-in Function:  fftconv (A, B, N)
  507.      Return the convolution of the vectors A and B, as a vector with
  508.      length equal to the `length (a) + length (b) - 1'.  If A and B are
  509.      the coefficient vectors of two polynomials, the returned value is
  510.      the coefficient vector of the product polynomial.
  511.      The computation uses the FFT by calling the function `fftfilt'.  If
  512.      the optional argument N is specified, an N-point FFT is used.
  513.  - Function File:  fftfilt (B, X, N)
  514.      With two arguments, `fftfilt' filters X with the FIR filter B
  515.      using the FFT.
  516.      Given the optional third argument, N, `fftfilt' uses the
  517.      overlap-add method to filter X with B using an N-point FFT.
  518.  - Loadable Function: y = filter (B, A, X)
  519.      Return the solution to the following linear, time-invariant
  520.      difference equation:
  521.              N                   M
  522.             SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)      for 1<=n<=length(x)
  523.             k=0                 k=0
  524.      where  N=length(a)-1 and M=length(b)-1.  An equivalent form of
  525.      this equation is:
  526.                       N                   M
  527.             y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)
  528.                      k=1                 k=0
  529.      where  c = a/a(1) and d = b/a(1).
  530.      In terms of the z-transform, y is the result of passing the
  531.      discrete- time signal x through a system characterized by the
  532.      following rational system function:
  533.                        M
  534.                       SUM d(k+1) z^(-k)
  535.                       k=0
  536.             H(z) = ----------------------
  537.                          N
  538.                     1 + SUM c(k+1) z(-k)
  539.                         k=1
  540.  - Loadable Function: [Y, SF] = filter (B, A, X, SI)
  541.      This is the same as the `filter' function described above, except
  542.      that SI is taken as the initial state of the system and the final
  543.      state is returned as SF.  The state vector is a column vector
  544.      whose length is equal to the length of the longest coefficient
  545.      vector minus one.  If SI is not set, the initial state vector is
  546.      set to all zeros.
  547.  - Function File: [H, W] = freqz (B, A, N, "whole")
  548.      Return the complex frequency response H of the rational IIR filter
  549.      whose numerator and denominator coefficients are B and A,
  550.      respectively.  The response is evaluated at N angular frequencies
  551.      between 0 and  2*pi.
  552.      The output value W is a vector of the frequencies.
  553.      If the fourth argument is omitted, the response is evaluated at
  554.      frequencies between 0 and  pi.
  555.      If N is omitted, a value of 512 is assumed.
  556.      If A is omitted, the denominator is assumed to be 1 (this
  557.      corresponds to a simple FIR filter).
  558.      For fastest computation, N should factor into a small number of
  559.      small primes.
  560.  - Function File:  sinc (X)
  561.      Return  sin(pi*x)/(pi*x).
  562. File: octave,  Node: Image Processing,  Next: Audio Processing,  Prev: Signal Processing,  Up: Top
  563. Image Processing
  564. ****************
  565.    Octave can display images with the X Window System using the
  566. `xloadimage' program.  You do not need to be running X in order to
  567. manipulate images, however, so some of these functions may be useful
  568. even if you are not able to view the results.
  569.    Loading images only works with Octave's image format (a file with a
  570. matrix containing the image data, and a matrix containing the
  571. colormap).  Contributions of robust, well-written functions to read
  572. other image formats are welcome.  If you can provide them, or would like
  573. to improve Octave's image processing capabilities in other ways, please
  574. contact (bug-octave@bevo.che.wisc.edu).
  575.  - Function File:  colormap (MAP)
  576.  - Function File:  colormap ("default")
  577.      Set the current colormap.
  578.      `colormap (MAP)' sets the current colormap to MAP.  The color map
  579.      should be an N row by 3 column matrix.  The columns contain red,
  580.      green, and blue intensities respectively.  All entries should be
  581.      between 0 and 1 inclusive.  The new colormap is returned.
  582.      `colormap ("default")' restores the default colormap (a gray scale
  583.      colormap with 64 entries).  The default colormap is returned.
  584.      With no arguments, `colormap' returns the current color map.
  585.  - Function File:  gray (N)
  586.      Return a gray colormap with N entries corresponding to values from
  587.      0 to N.  The argument N should be a scalar.  If it is omitted, 64
  588.      is assumed.
  589.  - Function File: [IMG, MAP] = gray2ind ()
  590.      Convert a gray scale intensity image to an Octave indexed image.
  591.  - Function File:  image (X, ZOOM)
  592.      Display a matrix as a color image.  The elements of X are indices
  593.      into the current colormap and should have values between 1 and the
  594.      length of the colormap.  If ZOOM is omitted, a value of 4 is
  595.      assumed.
  596.  - Function File:  imagesc (X, ZOOM)
  597.      Display a scaled version of the matrix X as a color image.  The
  598.      matrix is scaled so that its entries are indices into the current
  599.      colormap.  The scaled matrix is returned.  If ZOOM is omitted, a
  600.      value of 4 is assumed.
  601.  - Function File:  imshow (X, MAP)
  602.  - Function File:  imshow (X, N)
  603.  - Function File:  imshow (I, N)
  604.  - Function File:  imshow (R, G, B)
  605.      Display images.
  606.      `imshow (X)' displays an indexed image using the current colormap.
  607.      `imshow (X, MAP)' displays an indexed image using the specified
  608.      colormap.
  609.      `imshow (I, N)' displays a gray scale intensity image.
  610.      `imshow (R, G, B)' displays an RGB image.
  611.  - Function File:  ind2gray (X, MAP)
  612.      Convert an Octave indexed image to a gray scale intensity image.
  613.      If MAP is omitted, the current colormap is used to determine the
  614.      intensities.
  615.  - Function File: [R, G, B] = ind2rgb (X, MAP)
  616.      Convert an indexed image to red, green, and blue color components.
  617.      If MAP is omitted, the current colormap is used for the conversion.
  618.  - Function File: [X, MAP] = loadimage (FILE)
  619.      Load an image file and it's associated color map from the specified
  620.      FILE.  The image must be stored in Octave's image format.
  621.  - Function File:  rgb2ntsc (RGB)
  622.      Image format conversion.
  623.  - Function File:  ntsc2rgb (YIQ)
  624.      Image format conversion.
  625.  - Function File:  ocean (N)
  626.      Create color colormap.  The argument N should be a scalar.  If it
  627.      is omitted, 64 is assumed.
  628.  - Function File: [X, MAP] = rgb2ind (R, G, B)
  629.      Convert and RGB image to an Octave indexed image.
  630.  - Function File:  saveimage (FILE, X, FMT, MAP)
  631.      Save the matrix X to FILE in image format FMT.  Valid values for
  632.      FMT are
  633.     `"img"'
  634.           Octave's image format.  The current colormap is also saved in
  635.           the file.
  636.     `"ppm"'
  637.           Portable pixmap format.
  638.     `"ps"'
  639.           PostScript format.  Note that images saved in PostScript
  640.           format can not be read back into Octave with loadimage.
  641.      If the fourth argument is supplied, the specified colormap will
  642.      also be saved along with the image.
  643.      Note: if the colormap contains only two entries and these entries
  644.      are black and white, the bitmap ppm and PostScript formats are
  645.      used.  If the image is a gray scale image (the entries within each
  646.      row of the colormap are equal) the gray scale ppm and PostScript
  647.      image formats are used, otherwise the full color formats are used.
  648.  - Built-in Variable: IMAGEPATH
  649.      A colon separated list of directories in which to search for image
  650.      files.
  651. File: octave,  Node: Audio Processing,  Next: System Utilities,  Prev: Image Processing,  Up: Top
  652. Audio Processing
  653. ****************
  654.    Octave provides a few functions for dealing with audio data.  An
  655. audio `sample' is a single output value from an A/D converter, i.e., a
  656. small integer number (usually 8 or 16 bits), and audio data is just a
  657. series of such samples.  It can be characterized by three parameters:
  658. the sampling rate (measured in samples per second or Hz, e.g. 8000 or
  659. 44100), the number of bits per sample (e.g. 8 or 16), and the number of
  660. channels (1 for mono, 2 for stereo, etc.).
  661.    There are many different formats for representing such data.
  662. Currently, only the two most popular, *linear encoding* and *mu-law
  663. encoding*, are supported by Octave.  There is an excellent FAQ on audio
  664. formats by Guido van Rossum <guido@cwi.nl> which can be found at any
  665. FAQ ftp site, in particular in the directory
  666. `/pub/usenet/news.answers/audio-fmts' of the archive site
  667. `rtfm.mit.edu'.
  668.    Octave simply treats audio data as vectors of samples (non-mono data
  669. are not supported yet).  It is assumed that audio files using linear
  670. encoding have one of the extensions `lin' or `raw', and that files
  671. holding data in mu-law encoding end in `au', `mu', or `snd'.
  672.  - Function File:  lin2mu (X)
  673.      If the vector X represents mono audio data in 8- or 16-bit linear
  674.      encoding, `lin2mu (X)' is the corresponding mu-law encoding.
  675.  - Function File:  mu2lin (X, BPS)
  676.      If the vector X represents mono audio data in mu-law encoding,
  677.      `mu2lin' converts it to linear encoding.  The optional argument
  678.      BPS specifies whether the input data uses 8 bit per sample
  679.      (default) or 16 bit.
  680.  - Function File:  loadaudio (NAME, EXT, BPS)
  681.      Loads audio data from the file `NAME.EXT' into the vector X.
  682.      The extension EXT determines how the data in the audio file is
  683.      interpreted;  the extensions `lin' (default) and `raw' correspond
  684.      to linear, the extensions `au', `mu', or `snd' to mu-law encoding.
  685.      The argument BPS can be either 8 (default) or 16, and specifies
  686.      the number of bits per sample used in the audio file.
  687.  - Function File:  saveaudio (NAME, X, EXT, BPS)
  688.      Saves a vector X of audio data to the file `NAME.EXT'.  The
  689.      optional parameters EXT and BPS determine the encoding and the
  690.      number of bits per sample used in the audio file (see
  691.      `loadaudio');  defaults are `lin' and 8, respectively.
  692.    The following functions for audio I/O require special A/D hardware
  693. and operating system support.  It is assumed that audio data in linear
  694. encoding can be played and recorded by reading from and writing to
  695. `/dev/dsp', and that similarly `/dev/audio' is used for mu-law
  696. encoding.  These file names are system-dependent.  Improvements so that
  697. these functions will work without modification on a wide variety of
  698. hardware are welcome.
  699.  - Function File:  playaudio (NAME, EXT)
  700.  - Function File:  playaudio (X)
  701.      Plays the audio file `NAME.EXT' or the audio data stored in the
  702.      vector X.
  703.  - Function File:  record (SEC, SAMPLING_RATE)
  704.      Records SEC seconds of audio input into the vector X.  The default
  705.      value for SAMPLING_RATE is 8000 samples per second, or 8kHz.  The
  706.      program waits until the user types RET and then immediately starts
  707.      to record.
  708.  - Function File:  setaudio (TYPE)
  709.  - Function File:  setaudio (TYPE, VALUE)
  710.      Set or display various properties of your mixer hardware.
  711.      For example, if `vol' corresponds to the volume property, you can
  712.      set it to 50 (percent) by `setaudio ("vol", 50)'.
  713.      This is an simple experimental program to control the audio
  714.      hardware settings.  It assumes that there is a `mixer' program
  715.      which can be used as `mixer TYPE VALUE', and simply executes
  716.      `system ("mixer TYPE VALUE")'.  Future releases might get rid of
  717.      this assumption by using the `fcntl' interface.
  718. File: octave,  Node: System Utilities,  Next: Tips,  Prev: Audio Processing,  Up: Top
  719. System Utilities
  720. ****************
  721.    This chapter describes the functions that are available to allow you
  722. to get information about what is happening outside of Octave, while it
  723. is still running, and use this information in your program.  For
  724. example, you can get information about environment variables, the
  725. current time, and even start other programs from the Octave prompt.
  726. * Menu:
  727. * Timing Utilities::
  728. * Filesystem Utilities::
  729. * Controlling Subprocesses::
  730. * Process ID Information::
  731. * Environment Variables::
  732. * Current Working Directory::
  733. * Password Database Functions::
  734. * Group Database Functions::
  735. * System Information::
  736. File: octave,  Node: Timing Utilities,  Next: Filesystem Utilities,  Prev: System Utilities,  Up: System Utilities
  737. Timing Utilities
  738. ================
  739.    Octave's core set of functions for manipulating time values are
  740. patterned after the corresponding functions from the standard C library.
  741. Several of these functions use a data structure for time that includes
  742. the following elements:
  743. `usec'
  744.      Microseconds after the second (0-999999).
  745. `sec'
  746.      Seconds after the minute (0-61).  This number can be 61 to account
  747.      for leap seconds.
  748. `min'
  749.      Minutes after the hour (0-59).
  750. `hour'
  751.      Hours since midnight (0-23).
  752. `mday'
  753.      Day of the month (1-31).
  754. `mon'
  755.      Months since January (0-11).
  756. `year'
  757.      Years since 1900.
  758. `wday'
  759.      Days since Sunday (0-6).
  760. `yday'
  761.      Days since January 1 (0-365).
  762. `isdst'
  763.      Daylight Savings Time flag.
  764. `zone'
  765.      Time zone.
  766. In the descriptions of the following functions, this structure is
  767. referred to as a TM_STRUCT.
  768.  - Loadable Function:  time ()
  769.      Return the current time as the number of seconds since the epoch.
  770.      The epoch is referenced to 00:00:00 CUT (Coordinated Universal
  771.      Time) 1 Jan 1970.  For example, on Monday February 17, 1997 at
  772.      07:15:06 CUT, the value returned by `time' was 856163706.
  773.  - Function File:  ctime (T)
  774.      Convert a value returned from `time' (or any other nonnegative
  775.      integer), to the local time and return a string of the same form as
  776.      `asctime'.  The function `ctime (time)' is equivalent to `asctime
  777.      (localtime (time))'.  For example,
  778.           ctime (time ())
  779.                => "Mon Feb 17 01:15:06 1997"
  780.  - Loadable Function:  gmtime (T)
  781.      Given a value returned from time (or any nonnegative integer),
  782.      return a time structure corresponding to CUT.  For example,
  783.           gmtime (time ())
  784.                => {
  785.                      usec = 0
  786.                      year = 97
  787.                      mon = 1
  788.                      mday = 17
  789.                      sec = 6
  790.                      zone = CST
  791.                      min = 15
  792.                      wday = 1
  793.                      hour = 7
  794.                      isdst = 0
  795.                      yday = 47
  796.                    }
  797.  - Loadable Function:  localtime (T)
  798.      Given a value returned from time (or any nonnegative integer),
  799.      return a time structure corresponding to the local time zone.
  800.           localtime (time ())
  801.                => {
  802.                      usec = 0
  803.                      year = 97
  804.                      mon = 1
  805.                      mday = 17
  806.                      sec = 6
  807.                      zone = CST
  808.                      min = 15
  809.                      wday = 1
  810.                      hour = 1
  811.                      isdst = 0
  812.                      yday = 47
  813.                    }
  814.  - Loadable Function:  mktime (TM_STRUCT)
  815.      Convert a time structure corresponding to the local time to the
  816.      number of seconds since the epoch.  For example,
  817.           mktime (localtime (time ())
  818.                => 856163706
  819.  - Function File:  asctime (TM_STRUCT)
  820.      Convert a time structure to a string using the following five-field
  821.      format: Thu Mar 28 08:40:14 1996.  For example,
  822.           asctime (localtime (time ())
  823.                => "Mon Feb 17 01:15:06 1997\n"
  824.      This is equivalent to `ctime (time ())'.
  825.  - Loadable Function:  strftime (TM_STRUCT)
  826.      Format a time structure in a flexible way using `%' substitutions
  827.      similar to those in `printf'.  Except where noted, substituted
  828.      fields have a fixed size; numeric fields are padded if necessary.
  829.      Padding is with zeros by default; for fields that display a single
  830.      number, padding can be changed or inhibited by following the `%'
  831.      with one of the modifiers described below.  Unknown field
  832.      specifiers are copied as normal characters.  All other characters
  833.      are copied to the output without change.  For example,
  834.           strftime ("%r (%Z) %A %e %B %Y", localtime (time ())
  835.                => "01:15:06 AM (CST) Monday 17 February 1997"
  836.      Octave's `strftime' function supports a superset of the ANSI C
  837.      field specifiers.
  838.      Literal character fields:
  839.     `%'
  840.           % character.
  841.     `n'
  842.           Newline character.
  843.     `t'
  844.           Tab character.
  845.      Numeric modifiers (a nonstandard extension):
  846.     `- (dash)'
  847.           Do not pad the field.
  848.     `_ (underscore)'
  849.           Pad the field with spaces.
  850.      Time fields:
  851.     `%H'
  852.           Hour (00-23).
  853.     `%I'
  854.           Hour (01-12).
  855.     `%k'
  856.           Hour (0-23).
  857.     `%l'
  858.           Hour (1-12).
  859.     `%M'
  860.           Minute (00-59).
  861.     `%p'
  862.           Locale's AM or PM.
  863.     `%r'
  864.           Time, 12-hour (hh:mm:ss [AP]M).
  865.     `%R'
  866.           Time, 24-hour (hh:mm).
  867.     `%s'
  868.           Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard
  869.           extension).
  870.     `%S'
  871.           Second (00-61).
  872.     `%T'
  873.           Time, 24-hour (hh:mm:ss).
  874.     `%X'
  875.           Locale's time representation (%H:%M:%S).
  876.     `%Z'
  877.           Time zone (EDT), or nothing if no time zone is determinable.
  878.      Date fields:
  879.     `%a'
  880.           Locale's abbreviated weekday name (Sun-Sat).
  881.     `%A'
  882.           Locale's full weekday name, variable length (Sunday-Saturday).
  883.     `%b'
  884.           Locale's abbreviated month name (Jan-Dec).
  885.     `%B'
  886.           Locale's full month name, variable length (January-December).
  887.     `%c'
  888.           Locale's date and time (Sat Nov 04 12:02:33 EST 1989).
  889.     `%C'
  890.           Century (00-99).
  891.     `%d'
  892.           Day of month (01-31).
  893.     `%e'
  894.           Day of month ( 1-31).
  895.     `%D'
  896.           Date (mm/dd/yy).
  897.     `%h'
  898.           Same as %b.
  899.     `%j'
  900.           Day of year (001-366).
  901.     `%m'
  902.           Month (01-12).
  903.     `%U'
  904.           Week number of year with Sunday as first day of week (00-53).
  905.     `%w'
  906.           Day of week (0-6).
  907.     `%W'
  908.           Week number of year with Monday as first day of week (00-53).
  909.     `%x'
  910.           Locale's date representation (mm/dd/yy).
  911.     `%y'
  912.           Last two digits of year (00-99).
  913.     `%Y'
  914.           Year (1970-).
  915.    Most of the remaining functions described in this section are not
  916. patterned after the standard C library.  Some are available for
  917. compatiblity with MATLAB and others are provided because they are
  918. useful.
  919.  - Function File:  clock ()
  920.      Return a vector containing the current year, month (1-12), day
  921.      (1-31), hour (0-23), minute (0-59) and second (0-61).  For example,
  922.           clock ()
  923.                => [ 1993, 8, 20, 4, 56, 1 ]
  924.      The function clock is more accurate on systems that have the
  925.      `gettimeofday' function.
  926.  - Function File:  date ()
  927.      Return the date as a character string in the form DD-MMM-YY.  For
  928.      example,
  929.           date ()
  930.                => "20-Aug-93"
  931.  - Function File:  etime (T1, T2)
  932.      Return the difference (in seconds) between two time values
  933.      returned from `clock'.  For example:
  934.           t0 = clock ();
  935.           # many computations later...
  936.           elapsed_time = etime (clock (), t0);
  937.      will set the variable `elapsed_time' to the number of seconds since
  938.      the variable `t0' was set.
  939.  - Built-in Function: [TOTAL, USER, SYSTEM] = cputime ();
  940.      Return the CPU time used by your Octave session.  The first output
  941.      is the total time spent executing your process and is equal to the
  942.      sum of second and third outputs, which are the number of CPU
  943.      seconds spent executing in user mode and the number of CPU seconds
  944.      spent executing in system mode, respectively.  If your system does
  945.      not have a way to report CPU time usage, `cputime' returns 0 for
  946.      each of its output values.  Note that because Octave used some CPU
  947.      time to start, it is reasonable to check to see if `cputime' works
  948.      by checking to see if the total CPU time used is nonzero.
  949.  - Function File:  is_leap_year (YEAR)
  950.      Return 1 if the given year is a leap year and 0 otherwise.  If no
  951.      arguments are provided, `is_leap_year' will use the current year.
  952.      For example,
  953.           is_leap_year (2000)
  954.                => 1
  955.  - Function File:  tic ()
  956.  - Function File:  toc ()
  957.      These functions set and check a wall-clock timer.  For example,
  958.           tic ();
  959.           # many computations later...
  960.           elapsed_time = toc ();
  961.      will set the variable `elapsed_time' to the number of seconds since
  962.      the most recent call to the function `tic'.
  963.      If you are more interested in the CPU time that your process used,
  964.      you should use the `cputime' function instead.  The `tic' and
  965.      `toc' functions report the actual wall clock time that elapsed
  966.      between the calls.  This may include time spent processing other
  967.      jobs or doing nothing at all.  For example,
  968.           tic (); sleep (5); toc ()
  969.                => 5
  970.           t = cputime (); sleep (5); cputime () - t
  971.                => 0
  972.      (This example also illustrates that the CPU timer may have a fairly
  973.      coarse resolution.)
  974.  - Built-in Function:  pause (SECONDS)
  975.      Suspend the execution of the program.  If invoked without any
  976.      arguments, Octave waits until you type a character.  With a
  977.      numeric argument, it pauses for the given number of seconds.  For
  978.      example, the following statement prints a message and then waits 5
  979.      seconds before clearing the screen.
  980.           fprintf (stderr, "wait please...\n");
  981.           pause (5);
  982.           clc;
  983.  - Built-in Function:  sleep (SECONDS)
  984.      Suspend the execution of the program for the given number of
  985.      seconds.
  986.  - Built-in Function:  usleep (MICROSECONDS)
  987.      Suspend the execution of the program for the given number of
  988.      microseconds.  On systems where it is not possible to sleep for
  989.      periods of time less than one second, `usleep' will pause the
  990.      execution for `round (MICROSECONDS / 1e6)' seconds.
  991.